{extend name="../template/index/base.html"}
{block name="title"}友情链接-{$info['webname']}{/block}
{block name="keywords"}友情链接,{$info['keyword']}{/block}
{block name="description"}{$info['description']}{/block}
{block name="content"}	
<div class="layui-col-md8">
	<div class="layui-card">
		<h1 class="search-title">友情链接-携手共进</h1>
		<hr>
		<div class="link-con">
			{volist name="links" id="links"}
			<a href="{$links.url}">{$links.name}</a>
			{/volist}
		</div>
		<hr>
		<div class="layui-form layui-form-pane">
			<form class="link">
      {:token()}
				<div class="layui-form-item">
					<label class="layui-form-label">网址</label>
					<div class="layui-input-block">
						<input type="text" name="url" required="" lay-verify="url" placeholder="请输入你的网址" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">名称</label>
					<div class="layui-input-block">
						<input type="text" name="urlname" required="" lay-verify="required" placeholder="请输入名称(4个字)" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">邮箱</label>
					<div class="layui-input-block">
						<input type="text" name="email" required="" lay-verify="email" placeholder="请输入你的邮箱" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<button class="layui-btn fr" lay-filter="sendlink" lay-submit="submit">提交链接</button>
				</div>
			</form>
		</div>
	</div>
</div> 
{/block}
{block name="jssrc"}
<script type="text/javascript">
layui.use(['layer', 'form', 'element','jquery'], function(){
	var layer = layui.layer;
	form = layui.form;
	var $ = layui.$;
  form.on('submit(sendlink)', function(data){
    $.ajax({
      type:"POST",
      url:'./linkpost',
      dataType:"json",
      data: data.field,
      beforeSend: function () {
        $("#sendlink").attr({"disabled":"disabled"});
        $("#sendlink").addClass("layui-btn-disabled");
        $("#sendlink").html("正在提交中...");
        layer.load(1);
      },
      error: function (XmlHttpRequest, textStatus, errorThrown) {
        if (XmlHttpRequest.responseText != "") {
          layer.closeAll('loading');
          layer.msg('提交失败，请稍后尝试！');
          $("#sendlink").removeClass("layui-btn-disabled");
          $("#sendlink").removeAttr("disabled");  
          $("#sendlink").html("提交链接");
        }
      },
      success:function(data){
            if (data.result == "1") {
              layer.msg(data.msg);
              layer.closeAll('loading');
              $("#sendlink").removeClass("layui-btn-disabled");
              $("#sendlink").removeAttr("disabled");  
              $("#sendlink").html("提交链接");
              setTimeout(function(){
                location.reload();
              },1000);
            }else if(data.result = "2"){
              layer.closeAll('loading');
              layer.msg(data.msg);
              $("#sendlink").removeClass("layui-btn-disabled");
              $("#sendlink").removeAttr("disabled");  
              $("#sendlink").html("提交链接");

            }
          }
        });
    return false;
  });
});
</script>
{/block}